package com.hanfeng.client.adapter;

import java.util.ArrayList;

import com.hanfeng.client.entity.Music;
import com.hanfneg.client.db.MusicDAO;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class MusicListAdapter extends BaseAdapter {
	private ArrayList<Music> musics;
	private LayoutInflater inflater;
	private ListView lvmusic;
	private MusicDAO musicDAO;
	

	public MusicListAdapter(Context context,ArrayList<Music> musics, ListView lvmusic) {
		super();
		this.inflater = LayoutInflater.from(context);
		this.musics = musics;
		this.lvmusic = lvmusic;
		this.musicDAO = new MusicDAO(context);
	}
	
	/**
	 * 添加音乐
	 * @param music
	 */
	public void addMusic(Music music){
		if (musics!=null) {
			musics.add(music);;
			//动态更新ListView
			this.notifyDataSetChanged();
		}
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return musics.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return musics.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub

		return null;
	}
}
